package com.uu.safeguard.service.impl;

import com.uu.safeguard.dao.MemberRechargeLogDao;
import com.uu.safeguard.entity.MemberRechargeLog;
import com.uu.safeguard.service.MemberRechargeLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * (MemberRechargeLog)表服务实现类
 *
 * @author makejava
 * @since 2021-04-17 16:52:01
 */
@Service("memberRechargeLogService")
public class MemberRechargeLogServiceImpl implements MemberRechargeLogService {
    @Resource
    private MemberRechargeLogDao memberRechargeLogDao;
    /**
     * @Description: 单号查询充值详情
     * @Param: [refundLogSn]
     **/
    @Override
    public LinkedHashMap<String, Object> findRechargeLogBySn(String rechargeLogSn) {
        return memberRechargeLogDao.findRechargeLogBySn(rechargeLogSn);
    }

    /**
     * @Description: 本月充值
     * @Param: [operatorMemberSn]
     **/
    @Override
    public LinkedHashMap<String, Object> findMonthRecharge(String operatorMemberSn) {
        return memberRechargeLogDao.findMonthRecharge(operatorMemberSn);
    }

    /**
     * @Description: 充值柱状图
     * @Param: [operatorMemberSn, projectSn]
     **/
    @Override
    public LinkedHashMap<String, Object> findRechargeHistogram(String operatorMemberSn, String projectSn) {
        return memberRechargeLogDao.findRechargeHistogram(operatorMemberSn,projectSn);
    }

    /**
     * @Description: 运营商所有项目充值数据
     * @Param: [projectSn, operatorMemberSn, startTime, endTime]
     **/
    @Override
    public LinkedHashMap<String, Object> findProjectsRechargeProfit(String projectSn, String operatorMemberSn, Long startTime, Long endTime) {
        return memberRechargeLogDao.findProjectsRechargeProfit(projectSn,operatorMemberSn,startTime,endTime);
    }

    /**
     * @Description: 某日某月某年项目充值曲线
     * @Param: [projectSn, operatorMemberSn, startTime, endTime]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> findProjectRechargeCurveDay(String projectSn, String operatorMemberSn, Long startTime, Long endTime) {
        return memberRechargeLogDao.findProjectRechargeCurveDay(projectSn,operatorMemberSn,startTime,endTime);
    }

    @Override
    public List<LinkedHashMap<String, Object>> findProjectRechargeCurveMonth(String projectSn, String operatorMemberSn, Long startTime, Long endTime) {
        return memberRechargeLogDao.findProjectRechargeCurveMonth(projectSn,operatorMemberSn,startTime,endTime);
    }

    @Override
    public List<LinkedHashMap<String, Object>> findProjectRechargeCurveYear(String projectSn, String operatorMemberSn, Long startTime, Long endTime) {
        return memberRechargeLogDao.findProjectRechargeCurveYear(projectSn,operatorMemberSn,startTime,endTime);
    }

    /**
     * @Description: 某日 某月 某年 项目充值排行
     * @Param: [operatorMemberSn, startTime, endTime, startIndex, endIndex]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> findProjectRechargeSort(String projectSn,String operatorMemberSn, Long startTime, Long endTime, int pageIndex, int pageSize) {
        return memberRechargeLogDao.findProjectRechargeSort(projectSn,operatorMemberSn,startTime,endTime,(pageIndex-1)*pageSize,pageSize);
    }

    @Override
    public Integer findProjectRechargeSortCount(String projectSn,String operatorMemberSn, Long startTime, Long endTime) {
        return memberRechargeLogDao.findProjectRechargeSortCount(projectSn,operatorMemberSn,startTime,endTime);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public MemberRechargeLog queryById(Integer id) {
        return this.memberRechargeLogDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<MemberRechargeLog> queryAllByLimit(int offset, int limit) {
        return this.memberRechargeLogDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param memberRechargeLog 实例对象
     * @return 实例对象
     */
    @Override
    public MemberRechargeLog insert(MemberRechargeLog memberRechargeLog) {
        this.memberRechargeLogDao.insert(memberRechargeLog);
        return memberRechargeLog;
    }

    /**
     * 修改数据
     *
     * @param memberRechargeLog 实例对象
     * @return 实例对象
     */
    @Override
    public MemberRechargeLog update(MemberRechargeLog memberRechargeLog) {
        this.memberRechargeLogDao.update(memberRechargeLog);
        return this.queryById(memberRechargeLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.memberRechargeLogDao.deleteById(id) > 0;
    }
}